package com.lianxi

/**
  * Created by adengdeng on 2017/8/5 
  */
object Lx4 {

  /*
    翻译java for循环 ：
      for (int i=10; i>= 0;i--) System.out.println(i)
   */
  def main(args: Array[String]): Unit = {

    val time1 = System.currentTimeMillis()
    for(i <- 0 to 10 reverse) println(i)
    println(System.currentTimeMillis() - time1)

    //下面的方法的循环性能更高 reverse 方法导致的
    val time2 = System.currentTimeMillis()
    for(i <- 0 to 10; from = 10 - i) println(from)
    println(System.currentTimeMillis() - time2)

  }
}
